#!/usr/bin/env python
# -*- coding: utf-8 -*-
# title       :
# author      : jarry

import sys
import os
import logging
from SceneCheckTool.checkScript.CheckBase import CheckBase

try:
    import maya.cmds as cmds
    import pymel.core as pm
except:
    pass
import jarryLibs.mayakit.MayaUtils as mu
reload(mu)

logging.basicConfig()
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)


class CheckFPS(CheckBase):
    def __init__(self):
        super(CheckFPS, self).__init__()
        pass

    def check(self):
        fps = mu.getCurrentFPS()

        if fps != 24.0:
            result_log = u'Error:帧速率不正确，当前为%s\n' % fps
        else:
            result_log = u'Succeed:没有问题\n'
        return result_log
    
    def fix(self):
        fps = mu.getCurrentFPS()
        if fps != 24.0:
            try:
                cmds.currentUnit(time='film')
                result_log = u'Succeed:帧速率设置成功\n'
                log.info(result_log)
                return result_log
            except:
                result_log = u'Error:设置帧速率失败\n'
                log.error(result_log)
                return result_log
        else:
            return u'Succeed:没有问题\n'
